
Public Class frmProcessResultViewerTextFile

    Private _FileName As String

    Public Sub New(ByVal FileName As String, ByVal FileContents As String)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        _FileName = FileName
        txtFileName.Text = _FileName
        txtResultView.Text = FileContents
    End Sub

    Private Sub cmdExportToExcel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExportToExcel.Click
        Dim xlsapp As Excel.Application
        Try
            xlsapp = CType( _
                Microsoft.VisualBasic.Interaction.GetObject(, "Excel.Application") _
                , Excel.Application)
        Catch ex As Exception
            xlsapp = New Excel.Application
        End Try

        xlsapp.Visible = True

        Dim wbks As Excel.Workbooks = CType(xlsapp.Workbooks, Excel.Workbooks)
        Try
            wbks.OpenText( _
                Filename:=_FileName, DataType:=Excel.XlTextParsingType.xlDelimited, _
                TextQualifier:=Excel.XlTextQualifier.xlTextQualifierDoubleQuote, _
                ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _
                Comma:=False, Space:=False, Other:=False)
        Catch ex As Exception
            wbks = Nothing
            xlsapp = Nothing
        End Try
    End Sub

    Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
        Dim dlgResult As DialogResult = dlgSaveFile.ShowDialog
        If dlgResult = Windows.Forms.DialogResult.OK Then
            IO.File.Copy(_FileName, dlgSaveFile.FileName)
        End If
    End Sub
End Class
